using UnityEngine;
using System.Collections;

public class spheremove : MonoBehaviour {

	// Use this for initialization
	void Start () {
	}
	
	// Update is called once per frame
	void Update () {
		transform.Translate(Input.acceleration.x*30,0,Input.acceleration.y*30,Space.World);
		/*if(Input.GetKey(KeyCode.UpArrow))		
		{
			transform.Translate(0 , 0 , 200*Time.deltaTime);
		}
		if(Input.GetKey(KeyCode.DownArrow))		
		{
			transform.Translate(0 , 0 , -200*Time.deltaTime);
		}		
		if(Input.GetKey(KeyCode.LeftArrow))
		{
			transform.Translate( -200*Time.deltaTime , 0 , 0 );
		}		
		if(Input.GetKey(KeyCode.RightArrow))		
		{
			transform.Translate( 200*Time.deltaTime , 0 , 0);
		}*/

		Vector3 pos = transform.position;
		if(pos.x < 30){
			pos.x = 30;		
			transform.position = pos;
		}else if(pos.x > 930){
			pos.x = 930;
			transform.position = pos;
		}
		if(pos.z < 30){
			pos.z = 30;
			transform.position = pos;
		}else if(pos.z > 510){
			pos.z = 510;
			transform.position = pos;
		}
	}
	
	void OnTriggerEnter(Collider obj){
		if(obj.gameObject.name != "MainTerrain"
			&& obj.gameObject.name != "MyCounty"){
			Debug.Log("Collision---->"+obj.gameObject.name);			
			Destroy(obj.gameObject);			
		}
	}
	
	/*void OnCollisionEnter(Collision obj) {
		if(obj.gameObject.name != "MainTerrain"
			&& obj.gameObject.name != "MyCounty"){
			Debug.Log("Collision---->"+obj.gameObject.name);
			Destroy(obj.gameObject);
		}
	}*/
}
